package lanbo.cj.lmp.activity;

import cn.bmob.v3.BmobUser;
import lanbo.cj.lmp.R;
import lanbo.cj.lmp.view.DialogTips;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class SettingActivity extends Activity {
	private ImageView mBack;
	private RelativeLayout mInfo, mPwd, mCahse, mOperations, mAbout, mReply;
	private Button mBtn;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.setting);

		findviewBy();
		setListener();

	}

	private void findviewBy() {
		mBack = (ImageView) findViewById(R.id.setting_back);
		mInfo = (RelativeLayout) findViewById(R.id.setting_info);
		mPwd = (RelativeLayout) findViewById(R.id.setting_pwd);
		mCahse = (RelativeLayout) findViewById(R.id.setting_cashe);
		mOperations = (RelativeLayout) findViewById(R.id.setting_operations);
		mAbout = (RelativeLayout) findViewById(R.id.setting_about);
		mReply = (RelativeLayout) findViewById(R.id.setting_reply);
		mBtn = (Button) findViewById(R.id.setting_btn);
	}

	private void setListener() {
		mBack.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				finish();
			}
		});

		mInfo.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				Intent i = new Intent();
				i.setClass(SettingActivity.this, InfoActivity.class);
				startActivity(i);
			}
		});

		mPwd.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				Intent i = new Intent();
				i.setClass(SettingActivity.this,ChangePswActivity.class);
				startActivity(i);
			}
		});

		mCahse.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				DialogTips dialog = new DialogTips(SettingActivity.this, "清除缓存", "  确定清除缓存？", "确定", true, true);
				// 设置成功事件
				dialog.SetOnSuccessListener(new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialogInterface, int userId) {
						
					}
				});
				// 显示确认对话框
				dialog.show();
				dialog = null;
			}
		});

		mOperations.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				Intent i = new Intent(SettingActivity.this, HistoryActivity.class);
				i.putExtra("assetId","user");
				startActivity(i);
			}
		});

		mAbout.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
			
			//	aboutDialog.setMessage("程建出品");
				DialogTips dialog = new DialogTips(SettingActivity.this, "关于我们", "程健、陈祥出品", "确定", true, true);
				// 设置成功事件
				dialog.SetOnSuccessListener(new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialogInterface, int userId) {
						
					}
				});
				// 显示确认对话框
				dialog.show();
				dialog = null;
			}
		});

		mReply.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {

			}
		});

		mBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				BmobUser.logOut(SettingActivity.this);
				Intent i = new Intent(SettingActivity.this, LoginActivity.class);
				startActivity(i);
			}
		});
	}

}
